package com.caigou.modules.center.adapter

import android.text.TextUtils
import com.caigou.comm.base.utils.ImageLoader
import com.caigou.modules.center.R
import com.caigou.modules.center.bean.MyFansItemBean
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.module.LoadMoreModule
import com.chad.library.adapter.base.viewholder.BaseViewHolder

/**
 * @author #Suyghur.
 * Created on 2021/11/03
 */
class MyFansAdapter(dataset: MutableList<MyFansItemBean>) : BaseQuickAdapter<MyFansItemBean, BaseViewHolder>(R.layout.item_my_fans_list, dataset),
    LoadMoreModule {

    val checkStateList = mutableListOf<Boolean>()
    val removeUserIdList = mutableListOf<String>()

    override fun convert(holder: BaseViewHolder, item: MyFansItemBean) {
        checkStateList.add(getItemPosition(item), false)
        holder.setText(R.id.item_my_fans_tv_nickname, item.nickName)
        if (!TextUtils.isEmpty(item.headImg)) {
            ImageLoader.loadCircle(context, item.headImg, holder.getView(R.id.item_my_fans_iv_avatar))
        } else {
            holder.setImageResource(R.id.item_my_fans_iv_avatar, R.drawable.img_comm_avatar)
        }

//        holder.setImageResource(R.id.item_my_fans_iv_check, R.drawable.img_center_circle_uncheck)
//        holder.getView<ImageView>(R.id.item_my_fans_iv_check).visibility = View.GONE

//        holder.getView<ImageView>(R.id.item_my_fans_iv_check).setOnClickListener {
//            if (checkStateList[getItemPosition(item)]) {
//                holder.setImageResource(R.id.item_my_fans_iv_check, R.drawable.img_center_circle_uncheck)
//                checkStateList[getItemPosition(item)] = false
//                if (removeUserIdList.contains(item.userId)) {
//                    removeUserIdList.remove(item.userId)
//                }
//            } else {
//                checkStateList[getItemPosition(item)] = true
//                holder.setImageResource(R.id.item_my_fans_iv_check, R.drawable.img_center_circle_check)
//                removeUserIdList.add(item.userId)
//            }
//        }
    }
}